home *** CD-ROM | disk | FTP | other *** search
- /*
- File: EnetUser.h
-
- Contains: EnetUser includes
-
- Version: 1.0.0
-
- Copyright: © 1997-1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
-
- #ifndef __ENETUSER_H__
- #define __ENETUSER_H__
-
- /******************************************************************************/
-
- // The default MACOS is ON, MACH3 is OFF.
- #ifndef MACOS
- #define MACOS 1
- #define MACH3 0
- #endif
-
- /******************************************************************************/
-
- #if MACOS
-
- #ifdef __ENETLIB_H__
- #define OTKERNEL 1
- #endif
-
- #include "dlpiuser.h"
-
- #include <dlpi.h>
- #include <Resources.h>
-
- // This should be in OpenTransport.h
- enum {
- MIOC_ENET = 'E' /* ioctl's for Apple Enet */
- };
-
- // This should be in dlpiuser.h
- #define kMaxEnetStatus 16384
- #define IOC_ENETSTATUS MIOC_CMD(MIOC_ENET, 1) // retrieve status information
- #define IOC_ENETTEST MIOC_CMD(MIOC_ENET, 2) // run test and retrieve log and status
- #define IOC_ENETRESET MIOC_CMD(MIOC_ENET, 3) // reset and retrieve log and status
- #define IOC_ENETLOG MIOC_CMD(MIOC_ENET, 4) // retrieve log information
- #define IOC_DLPITEST MIOC_CMD(MIOC_ENET, 5)
- #define IOC_DLPITEST_RESET 0x00000000 // reset to normal operation
- #define IOC_DLPITEST_TX_BLOCK 0x00000001 // block transmitter
- #define IOC_DLPITEST_TX_UNBLOCK 0x00000002 // unblock transmitter
- #define IOC_DLPITEST_PROMISCUOUS 0x00000003 // disable external address filter
- #define IOC_DLPITEST_FILTER 0x00000004 // enable external address filter
- #define IOC_DLPITEST_INTERNAL 0x00000005 // disable external network access
- #define IOC_DLPITEST_EXTERNAL 0x00000006 // enable external network access
- #ifdef MIOC_ND
- #define ND_GET MIOC_CMD(MIOC_ND, 0)
- #define ND_SET MIOC_CMD(MIOC_ND, 1)
- #else
- #define ND_GET MIOC_CMD(MIOC_ENET, 6)
- #define ND_SET MIOC_CMD(MIOC_ENET, 7)
- #endif
-
- // This should be in dlpiuser.h
- enum {
- DL_NO_ERROR = 0x00,
- DL_MAC_ERROR = 0x08
- };
-
- // Enet Virtual Controller for support of Mac and PC clients
-
- #define I_VirtualControllerIoctl 6001
-
- enum VirtualControllerOptions {
- kVCCreateController = 0x00000001,
- kVCAssignController = 0x00000002,
- kVCEnableStandardMode = 0x00000004,
- kVCEnablePaddingMode = 0x00000008,
- kVCEnableCRCMode = 0x00000010,
- kVCEnablePromiscuousMode = 0x00000020
- };
-
- typedef struct VCRequest VCRequest;
- typedef VCRequest *VCRequestPtr;
- struct VCRequest {
- UInt16 vcOptions;
- UInt16 vcID;
- };
-
- // ENETShim mode for supporting .enet driver on PCI machines
-
- #define kOTENETShimIoctl 6000
-
- enum ENETtoDLPICommands {
- kSetEthernetAddress = 1,
- kSNMPDot3Entry = 2,
- kSNMPDot3Stats = 3,
- kSNMPLapMIBStats = 4,
- kENETShimAddQTCHack = 10,
- kENETShimDeleteQTCHack = 11,
- kSetENETShimStreamType = 12,
- kSetENETShimPromiscOn = 13,
- kSetENETShimPromiscOff = 14
- };
-
- typedef struct ENETShimRequest ENETShimRequest;
- typedef ENETShimRequest *ENETShimRequestPtr;
- struct ENETShimRequest {
- UInt16 enetCommand;
- UInt16 enetSize;
- void * enetAddress;
- };
-
- //#include <SNMPLAP.h>
-
- struct Dot3Entry {
- unsigned long dot3Version; /* Version of LapDot3 entry that we support */
- unsigned long dot3Index; /* ifIndex for this driver */
- unsigned long dot3InitializeMac; /* Init status (1 = inited, 2 = uninited) */
- unsigned long dot3MacSubLayerStatus; /* Op status of the MAC sublayer (1 = enabled, 2 = disabled) */
- unsigned long dot3MulticastReceiveStatus; /* Multicast receive status (1 = enabled, 2 = disabled) */
- unsigned long dot3TxEnabled; /* MAC frame tx state (1 = enabled, 2 = disabled) */
- unsigned long dot3TestTdrValue; /* Time between TDR start/end */
- };
- typedef struct Dot3Entry Dot3Entry;
-
- #define SNMPVersion 0x100 /* used for LAPMIBStats, Dot3Stats, Dot3Entry */
-
- // dot3InitializeMac
- enum {
- dot3initialized = 1,
- dot3uninitialized = 2
- };
-
- // dot3SubLayerStatus, dot3MulticastReceiveStatus
- enum {
- dot3enabled = 1,
- dot3disabled = 2
- };
-
- // dot3TxEnabled, dot5ActMonParticipate
- enum {
- dot_true = 1,
- dot_false = 2
- };
-
- struct Dot3StatsEntry {
- unsigned long dot3StatsVersion; /* Version number */
- unsigned long dot3StatsIndex; /* Same as ifIndex (to be left at zero) */
- unsigned long dot3StatsAlignmentErrors;
- unsigned long dot3StatsFCSErrors;
- unsigned long dot3StatsSingleCollisionFrames;
- unsigned long dot3StatsMultipleCollisionFrames;
- unsigned long dot3StatsSQETestErrors;
- unsigned long dot3StatsDeferredTransmissions;
- unsigned long dot3StatsLateCollisions;
- unsigned long dot3StatsExcessiveCollisions;
- unsigned long dot3StatsInternalMacTransmitErrors;
- unsigned long dot3StatsCarrierSenseErrors;
- unsigned long dot3StatsExcessiveDeferrals;
- unsigned long dot3StatsFrameTooLongs;
- unsigned long dot3StatsInRangeLengthErrors;
- unsigned long dot3StatsOutOfRangeLengthFields;
- unsigned long dot3StatsInternalMacReceiveErrors;
- };
- typedef struct Dot3StatsEntry Dot3StatsEntry;
-
- struct LAPMIBStats {
- unsigned long ifVersion; /* Version of LinkStats we support */
- Str255 ifDescr; /* String with info about interface */
- unsigned long ifType; /* Code with type of interface */
- unsigned long ifMaxMTU; /* Largest size of IP datagram that can be tx/recv */
- unsigned long ifSpeed; /* Bandwidth in bits/second */
- Str31 ifPhysAddress; /* Interface address */
- unsigned long ifAdminStatus; /* Desired state (1 = up, 2 = down, 3 = testing) */
- unsigned long ifOperStatus; /* Current state (1 = up, 2 = down, 3 = testing) */
- unsigned long ifLastChange; /* SysTicks when interface entered current operation state */
- unsigned long ifInOctets; /* Total nbr bytes received including framing chars*/
- unsigned long ifInUcastPkts; /* Nbr of unicast packets received */
- unsigned long ifInNUcastPkts; /* Nbr of broad/multi cast packets received */
- unsigned long ifInDiscards; /* Nbr of overwrites that occured */
- unsigned long ifInErrors; /* Nbr of pkts recv which contain error */
- unsigned long ifInUnknownProtos; /* Nbr of pkts recv discarded cuz of unknown protocol */
- unsigned long ifOutOctets; /* Total nbr bytes tx including framing chars */
- unsigned long ifOutUcastPkts; /* Nbr of unicast packets tx */
- unsigned long ifOutNUcastPkts; /* Nbr of broad/multi cast packets tx */
- unsigned long ifOutDiscards; /* Nbr tx pkts discarded */
- unsigned long ifOutErrors; /* Nbr tx pkts not sent due to error */
- unsigned long ifOutQLen; /* Current nbr of packets in output queue */
- };
- typedef struct LAPMIBStats LAPMIBStats;
-
- // ifAdminStatus and ifOperStatus
- enum {
- ifStatusUp = 1,
- ifStatusDown = 2,
- ifStatusTesting = 3
- };
-
- // IfTypes
- enum {
- other = 1, /* none of the following */
- regular1822 = 2,
- hdh1822 = 3,
- ddn_x25 = 4,
- rfc877_x25 = 5,
- ethernet_csmacd = 6,
- iso88023_csmacd = 7,
- iso88024_tokenBus = 8,
- iso88025_tokenRing = 9,
- iso88026_man = 10,
- starLan = 11,
- proteon_10Mbit = 12,
- proteon_80Mbit = 13,
- hyperchannel = 14,
- fddi = 15,
- lapb = 16,
- sdlc = 17,
- ds1 = 18, /* T-1 */
- e1 = 19, /* european equivalent of T-1 */
- basicISDN = 20,
- primaryISDN = 21,
- propPointToPointSerial = 22, /* proprietary serial */
- ppp = 23,
- softwareLoopback = 24,
- eon = 25, /* CLNP over IP */
- ethernet_3Mbit = 26,
- nsip = 27, /* XMS over IP */
- slip = 28, /* generic SLIP */
- ultra = 29, /* ULTRA technologie */
- ds3 = 30, /* T-3 */
- sip = 31, /* SMDS */
- frame_relay = 32
- };
-
- #endif // MACOS
-
- #if MACH3
- #endif // MACH3
-
- // Where should these be?
- #define kTestProto 0x809B
- #define kEchoProto 0x809D
-
- enum {
- kEnetMaxTSDU = 1514,
- kEnetMinTSDU = 14,
- kEnetMaxRSDU = kEnetMaxTSDU + sizeof(UInt32),
- kEnetMinRSDU = kEnetMinTSDU + sizeof(UInt32)
- };
-
- typedef UInt8 EnetAddress[6];
- typedef UInt8 * EnetAddressPtr;
-
- typedef struct EnetHeader EnetHeader;
- typedef EnetHeader *EnetHeaderPtr;
- struct EnetHeader
- {
- UInt8 fDestAddr[6];
- UInt8 fSourceAddr[6];
- UInt16 fProto;
- };
-
- // CompareEnetAddress() compares two ethernet addresses.
- // Returns false if they are not equal.
- #define CompareEnetAddress(a1, a2) \
- ((*(const UInt32*)((const UInt8*)(a1)) == \
- *(const UInt32*)((const UInt8*)(a2))) && \
- (*(const UInt16*)(((const UInt8*)(a1))+4) == \
- *(const UInt16*)(((const UInt8*)(a2))+4)))
-
- // CopyEnetAddress() copies an ethernet address.
- #define CopyEnetAddress(s, d) \
- (*(UInt32*)((UInt8*)(d)) = \
- *(const UInt32*)((const UInt8*)(s)), \
- *(UInt16*)(((UInt8*)(d))+4) = \
- *(const UInt16*)(((const UInt8*)(s))+4) )
-
- // IsEnetAddressMulticast() checks for a multicast address.
- // Returns false if the specified address is not a multicast address.
- #define IsEnetAddressMulticast(a) \
- (((const UInt8*)(a))[0] & 0x01)
-
- // IsEnetAddressBroadcast() checks for a broadcast address.
- // Returns false if the specified address is not a broadcast address.
- #define IsEnetAddressBroadcast(a) \
- ((*(const UInt32*)((const UInt8*)(a)) == 0xFFFFFFFF) && \
- (*(const UInt16*)(((const UInt8*)(a))+4) == 0xFFFF))
-
- // SetBroadcastEnetAddress() sets a broadcast address value.
- #define SetBroadcastEnetAddress(a) \
- (*(UInt32*)((UInt8*)(a)) = 0xFFFFFFFF, \
- *(UInt16*)(((UInt8*)(a))+4) = 0xFFFF )
-
- // IsEnetAddressZero() checks for a zero address.
- // Returns false if the specified address is not zero.
- #define IsEnetAddressZero(a) \
- (!*(const UInt32*)((const UInt8*)(a)) && \
- !*(const UInt16*)(((const UInt8*)(a))+4))
-
- // IsEnetAddressZeroMisaligned() checks for a zero address.
- // Returns false if the specified address is not zero.
- // This variant of IsEnetAddressZero is specially for use with
- // the source address of an Ethernet packet, which starts at
- // the sixth byte of the packet (i.e. it is not long-word aligned).
- #define IsEnetAddressZeroMisaligned(a) \
- (!*(const UInt16*)((const UInt8*)(a)) && \
- !*(const UInt32*)(((const UInt8*)(a))+2))
-
- // SetEnetAddressZero() sets a zero address value.
- #define SetEnetAddressZero(a) \
- (*(UInt32*)((UInt8*)(a)) = 0, \
- *(UInt16*)(((UInt8*)(a))+4) = 0 )
-
- #define IsValidUnicastAddress(a) \
- (IsEnetAddressZero(a) ? 0 : \
- (IsEnetAddressBroadcast(a) ? 0 : \
- (IsEnetAddressMulticast(a) ? 0 : 1)))
- #endif // __ENETUSER_H__
-